package com.example.flower_shop.enums;

import lombok.Getter;

import java.util.Locale;

@Getter
public enum PayType {
    WECHAT("wechat", "微信支付"),
    ALI_PAY("alipay", "支付宝支付");
    private final String type;
    private final String name;

    PayType(String type, String name) {
        this.type = type;
        this.name = name;
    }

    public static void validate(String type) {
        type = type.trim().toLowerCase(Locale.ROOT);
        for (PayType payType : PayType.values()) {
            if (payType.getType().equals(type)) {
                return;
            }
        }
        throw new IllegalArgumentException("支付方式不存在");
    }
}
